home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / laby.zip / LABY.C next >
C/C++ Source or Header  |  1992-12-24  |  19KB  |  877 lines

  1. /* Labyrinth by Russell Wallace. Info in instructions within game. Developed
  2.    using Aztec C. Use short integer compile option. Must be linked with
  3.    intro1, intro2, intro3, strcomp, rnd and cliwindow object files. Please
  4.    distribute this source code along with object code.
  5.  
  6.    This is the new slightly improved version. Forget about cliwindow, put
  7.    input.o and console.o at the end of the link list instead - both those
  8.    require the +L compile option with Aztec C. Also printnum.o (short int.)
  9.  
  10.    9 July 1988 version 1.01 recompiled with Aztec C 3.4a. Use makefile in
  11.    this directory to recompile.
  12.  
  13.    8 November 1988 version 2.0 compiled with Aztec C 3.4a. Use makefile to
  14.    compile.
  15.  
  16.     24 January 1991 ported to MS-DOS with Turbo C++
  17. */
  18.  
  19. #define TRUE 1
  20. #define FALSE 0
  21. #define MAXBUF 256
  22.  
  23. #define NUMCHAR 28    /* number of computer-controlled characters */
  24. #define NUMCOIN 300
  25. #define NUMTYPE 8    /* number of types of weapons */
  26. #define NUMWEAP 6    /* number of weapons of each type */
  27. #define INLEN 256    /* maximum input length */
  28. #define WORDLEN 10    /* length of typed-in words i.e. names */
  29. #define MAXX 19     /* width of play area -1 */
  30. #define MAXY 19     /* height of play area -1 */
  31. #define NUMLOC 400    /* number of locations */
  32. #define NOWHERE -999    /* this location number means nonexistent */
  33.  
  34. #define xc(pos) ((pos-1)%20)        /* x-coordinate for location number */
  35. #define yc(pos) ((pos-1)/20)        /* y-coordinate */
  36. #define rnd(x)  (rand () % x)
  37.  
  38. #include    <stdio.h>
  39. #include    <stdlib.h>
  40. #include    <dos.h>
  41.  
  42. typedef char boolean;
  43.  
  44. boolean alldead;    /* All computer controlled characters dead */
  45. boolean taken;        /* Character taken object */
  46. boolean global;     /* Global narration selected */
  47. boolean verbose;    /* Verbose mode on */
  48. boolean dead;        /* Character dead */
  49. boolean err;        /* Command returns error */
  50. boolean see;        /* Describe location */
  51. boolean fought;     /* Character has engaged in combat for this turn */
  52.  
  53. char key;
  54. char *command;    /* Pointer to input buffer with command typed by player */
  55. char target[WORDLEN];    /* Name of person player wants to attack */
  56. char inword[WORDLEN];    /* Word from command string */
  57. char inputbuffer[MAXBUF];
  58.  
  59. short i,j;        /* General purpose loop counter variables */
  60. short index,z;
  61. short thing;        /* Thing (weapon or coin) referred to */
  62. short weapon;        /* Weapon being operated on */
  63. short tarnum;        /* Number of target character for attack */
  64. short atstre;        /* Strength of attack */
  65. short atweap;        /* Weapon used in attack */
  66. short charpos[NUMCHAR+1];   /* position of each character (player is char 0) */
  67. short strength[NUMCHAR+1];  /* current strength, reduced by combat */
  68.                 /* if drops to 0, then death */
  69. short power[NUMCHAR+1];     /* maximum strength, increases if win fight */
  70. short coinpos[NUMCOIN+1],weapos[NUMTYPE+1][NUMWEAP+1];
  71. short score;            /* player's score accumulated for several games */
  72. short temppos;            /* temporary for character position */
  73.  
  74. long start ();
  75. char *getstring ();
  76.  
  77. short hitval[NUMTYPE+1]=    /* attack value of each object type */
  78. {
  79.     0,
  80.     80,105,52,110,47,49,22,12
  81. };
  82.  
  83. char *obj_desc[]=
  84. {
  85.     "",
  86.     " axe",
  87.     " sword",
  88.     " club",
  89.     " mace",
  90.     " knife",
  91.     " dagger",
  92.     " fist",
  93.     " coin"
  94. };
  95.  
  96. char *loc_adj[]=
  97. {
  98.     "dark ",
  99.     "dank ",
  100.     "damp ",
  101.     "draughty ",
  102.     "large ",
  103.     "stony ",
  104.     "long ",
  105.     "small ",
  106.     "pokey "
  107. };
  108.  
  109. char *loc_noun[]=
  110. {
  111.     "cave.\n",
  112.     "cavern.\n",
  113.     "dungeon.\n",
  114.     "tunnel.\n",
  115.     "hallway.\n",
  116.     "room.\n",
  117.     "corridor.\n",
  118.     "hall.\n",
  119.     "chamber.\n"
  120. };
  121.  
  122. char name_initial[]=      /* Initial letters of all the objects */
  123. {
  124.     0,'a','s','c','m','k','d','f','c'
  125. };
  126.  
  127. char *person_name[]=
  128. {
  129.     "",
  130.     "David Watchorn",
  131.     "Shane Broadberry",
  132.     "Tara Morris",
  133.     "Paul Whelan",
  134.     "Bob Gray",
  135.     "Garrett Simons",
  136.     "Ian O'Keeffe",
  137.     "Jason O'Brien",
  138.     "Norman Ruddock",
  139.     "Alan Callender",
  140.     "Allen Dunne",
  141.     "Nigel Waterhouse",
  142.     "Nigel Cobbe",
  143.     "Neill Spotswood",
  144.     "Ruth Whittaker",
  145.     "Ruth Laycock",
  146.     "Susan Carroll",
  147.     "Gillian Nother",
  148.     "Hilary Usher",
  149.     "Tara O'Rourke",
  150.     "Sarah Gilliland",
  151.     "Sarah Lessen",
  152.     "Jennifer Gilliland",
  153.     "Jennifer Nother",
  154.     "Penny Jackson",
  155.     "Emma Kelly",
  156.     "Joanna Williams",
  157.     "Fiona McDowell"
  158. };
  159.  
  160. char *pername[]=
  161. {
  162.     "",
  163.     "david",
  164.     "shane",
  165.     "tara",
  166.     "paul",
  167.     "bob",
  168.     "garrett",
  169.     "ian",
  170.     "jason",
  171.     "norman",
  172.     "alan",
  173.     "allen",
  174.     "nigel",
  175.     "nigel",
  176.     "neill",
  177.     "ruth",
  178.     "ruth",
  179.     "susan",
  180.     "gillian",
  181.     "hilary",
  182.     "tara",
  183.     "sarah",
  184.     "sarah",
  185.     "jennifer",
  186.     "jennifer",
  187.     "penny",
  188.     "emma",
  189.     "joanna",
  190.     "fiona"
  191. };
  192.  
  193. int printx,printy;
  194.  
  195. waitinput ()
  196. {
  197.     fflush (stdout);
  198.     printy = 0;
  199.     return bioskey (0) & 0x00ff;
  200. }
  201.  
  202. void xprintc (int c)
  203. {
  204.     putchar (c);
  205. }
  206.  
  207. void xprintn (char *s,int i)
  208. {
  209.     while (--i >= 0)
  210.         putchar (*s++);
  211. }
  212.  
  213. void xprint (char *s)
  214. {
  215.     while (*s)
  216.         putchar (*s++);
  217. }
  218.  
  219. void printmore ()
  220. {
  221.     xprint ("MORE...");
  222.     waitinput ();
  223.     xprint ("\r       \r");
  224.     printx = 0;
  225. }
  226.  
  227. void print (char *s)
  228. {
  229.     int i;
  230.     if (!s)
  231.         return;
  232.     do
  233.     {
  234.         i = 0;
  235.         while (s[i]!=0 && s[i]!=' ' && s[i]!='\n')
  236.             i++;
  237.         if (printx + i >= 79)
  238.         {
  239.             xprintc ('\n');
  240.             printx = 0;
  241.             printy++;
  242.             if (printy >= 24)
  243.                 printmore ();
  244.         }
  245.         xprintn (s,i);
  246.         printx += i;
  247.         s += i;
  248.         while (*s == ' ' || *s == '\n')
  249.         {
  250.             xprintc (*s);
  251.             printx++;
  252.             if (*s == '\n')
  253.             {
  254.                 printx = 0;
  255.                 printy++;
  256.                 if (printy >= 24)
  257.                     printmore ();
  258.             }
  259.             s++;
  260.         }
  261.     }
  262.     while (*s);
  263. }
  264.  
  265. void writechar (int c)
  266. {
  267.     char s[2];
  268.     s[1] = 0;
  269.     s[0] = c;
  270.     print (s);
  271.     if (c == '\n')
  272.         printx = 0;
  273. }
  274.  
  275. void printnum (int n)
  276. {
  277.     char s[12];
  278.     sprintf (s,"%d",n);
  279.     print (s);
  280. }
  281.  
  282. input (char *s,int n)
  283. {
  284.     gets (s);
  285.     printx = printy = 0;
  286.     return 0;
  287. }
  288.  
  289. boolean legal (pos)     /* Is location enterable or solid rock? */
  290. short pos;
  291. {
  292.     if ((xc (pos)<0)||(xc (pos)>MAXX)||(yc (pos)<0)||(yc (pos)>MAXY))
  293.     return (FALSE); /* if outside play area, obviously illegal */
  294.     if ((xc (pos)%2==0)&&(yc (pos)%2==0))
  295.     return (FALSE); /* also if in one of grid of "pillars" */
  296.         else
  297.         return (TRUE);
  298. }
  299.  
  300. short numcoin (pos)     /* number of coins in location */
  301.             /* remember "location" 0..-28 means carried by character */
  302. short pos;
  303. {
  304.     short i;
  305.     short nc=0;
  306.     for (i=1;i<=NUMCOIN;i++)
  307.     if (coinpos[i]==pos)
  308.         nc++;
  309.     return (nc);
  310. }
  311.  
  312. short numweap (pos,w)   /* number of weapons of type w in location */
  313. short pos,w;
  314. {
  315.     short i;
  316.     short nw=0;
  317.     for (i=1;i<=NUMWEAP;i++)
  318.     if (weapos[w][i]==pos)
  319.         nw++;
  320.     return (nw);
  321. }
  322.  
  323. short numpos (pos)      /* number of possessions (weapons+coins) in loc. */
  324. short pos;
  325. {
  326.     short i;
  327.     short np=0;
  328.     for (i=1;i<=NUMTYPE-2;i++)
  329.     np+=numweap (pos,i);
  330.     return (np+numcoin (pos));
  331. }
  332.  
  333. rlook (pos)     /* Give text for location. This might be considered even */
  334.         /* more inelegant than the above, but repeated ifs with */
  335.         /* only one line each are more compact than a case. */
  336. {
  337.     print (" a ");
  338.     print (loc_adj[(xc (pos)^yc (pos))%9]);
  339.     print (loc_noun[((xc (pos)+1)^(yc (pos)+2))%9]);
  340. }
  341.  
  342. look (pos)  /* look at a location from adjoining one */
  343. short pos;
  344. {
  345.     if (legal (pos)==FALSE)
  346.     print (" solid rock.\n");
  347.         else
  348.         rlook (pos);
  349. }
  350.  
  351. locdesc (pos)   /* describe stuff in location */
  352. short pos;
  353. {
  354.     short i;
  355.     for (i=1;i<=NUMTYPE-2;i++)
  356.     {
  357.     if (numweap (pos,i)>0)
  358.     {
  359.         printnum (numweap (pos,i));
  360.         print (obj_desc[i]);
  361.         if (numweap (pos,i)!=1)
  362.         writechar ('s');
  363.         writechar ('\n');
  364.     }
  365.     }
  366.     if (numcoin (pos)>0)
  367.     {
  368.     printnum (numcoin (pos));
  369.     print (" coin");
  370.     if (numcoin (pos)!=1)
  371.         writechar ('s');
  372.     writechar ('\n');
  373.     }
  374. }
  375.  
  376. getword (string)    /* splits word off string, puts it in inword */
  377. char *string;
  378. {
  379.     short i,j;
  380.     do
  381.     index++;
  382.     while (index<INLEN && string[index]!=' ');
  383.     i=++index;
  384.     for (j=0;j<WORDLEN && string[i]>='a' && string[i]<='z';j++)
  385.     inword[j]=string[i++];
  386.     if (j<WORDLEN)
  387.     inword[j]='\0';
  388. }
  389.  
  390. short getname (string)  /* which object is being referred to? */
  391. char *string;
  392. {
  393.     int i;
  394.     getword (string);
  395.     if (inword[0]=='w')
  396.     getword (string);   /* ignore "with" */
  397.     for (i=1;i<=8 && name_initial[i]!=inword[0];i++)
  398.     ;
  399.     if (i==3 && inword[1]=='o')
  400.     i=8;
  401.     if (i==9)
  402.     {
  403.     print ("There's no such object in this game!\n");
  404.     i=0;
  405.     }
  406.     return i;
  407. }
  408.  
  409. thing8 (first,second)
  410. short first,second;
  411. {
  412.     short i;
  413.     if (numcoin (first)==0)
  414.     err=TRUE;
  415.         else
  416.             for (i=1;i<=NUMCOIN;i++)
  417.                 if (coinpos[i]==first)
  418.                     coinpos[i]=second;
  419. }
  420.  
  421. weaptake (first,second,thing)
  422. short first,second,thing;
  423. {
  424.     short i;
  425.     for (i=1;i<=NUMWEAP;i++)
  426.     if (weapos[thing][i]==first)
  427.         weapos[thing][i]=second;
  428. }
  429.  
  430. move (first,second,thing)
  431. short first,second,thing;
  432. {
  433.     err=FALSE;
  434.     if (thing==8)
  435.     thing8 (first,second);
  436.     if (thing==0 || thing==7)
  437.     err=TRUE;
  438.     if (thing!=0 && thing<7)
  439.     {
  440.         if (numweap (first,thing))
  441.             weaptake (first,second,thing);
  442.             else
  443.                 err=TRUE;
  444.     }
  445. }
  446.  
  447. drop (person,thing)
  448. short person,thing;
  449. {
  450.     move (-person,charpos[person],thing);
  451. }
  452.  
  453. perdesc (p,wordcase)        /* Oh God, not again! */
  454. short p,wordcase;
  455. {
  456.     if (p==0)
  457.     {
  458.         if (wordcase)
  459.             print ("You");
  460.         else
  461.             print ("you");
  462.         return;
  463.     }
  464.     print (person_name[p]);
  465. }
  466.  
  467. narrate (offense,defense,weapon)
  468. short offense,defense,weapon;
  469. {
  470.     perdesc (offense,1);
  471.     if (offense==0)
  472.     print (" hit ");
  473.         else
  474.         print (" hits ");
  475.     perdesc (defense,0);  /* Object of sentence */
  476.     if (weapon==1)
  477.     print (" with an");
  478.         else
  479.         print (" with a");
  480.     print (obj_desc[weapon]);
  481.     writechar ('.');
  482. }
  483.  
  484. attack (offense,defense,weapon)
  485. short offense,defense,weapon;
  486. {
  487.     short i;
  488.     strength[defense]-=hitval[weapon];
  489.     if (strength[defense]<1)
  490.     {
  491.     for (i=1;i<=NUMTYPE-2;i++)
  492.         drop (defense,i);   /* drop weapons of dead victim */
  493.     drop (defense,8);       /* drop coins */
  494.     temppos=charpos[defense];
  495.     charpos[defense]=NOWHERE;
  496.     power[offense]+=power[defense]/4;
  497.     }
  498.     if (charpos[offense]==charpos[0])
  499.     {
  500.     narrate (offense,defense,weapon);
  501.     writechar ('\n');
  502.     }
  503.     else
  504.         if (global)
  505.         {
  506.         writechar ('(');
  507.         narrate (offense,defense,weapon);
  508.         print (")\n");
  509.         }
  510.     if (strength[0]<1 && defense==0)
  511.     {
  512.     print ("You have died.\n");
  513.     dead=TRUE;
  514.     }
  515.     if (strength[defense]<0 && defense && (global || temppos==charpos[0]))
  516.     {
  517.     if (temppos!=charpos[0])
  518.         writechar ('(');
  519.     perdesc (defense,1);
  520.     print (" dies.");
  521.     if (temppos!=charpos[0])
  522.         writechar (')');
  523.     writechar ('\n');
  524.     }
  525. }
  526.  
  527. population (pos)    /* Tell who else is here */
  528. short pos;
  529. {
  530.     short i;
  531.     for (i=1;i<=NUMCHAR;i++)
  532.     {
  533.     if (charpos[i]==pos)
  534.     {
  535.         perdesc (i,1);
  536.         print (" is here.\n");
  537.         if (numpos (-i))
  538.         {
  539.         if (i<15)
  540.             print ("He is carrying:\n");
  541.             else
  542.                 print ("She is carrying:\n");
  543.         locdesc (-i);
  544.         }
  545.         if (i<15)
  546.         print ("His strength is ");
  547.             else
  548.             print ("Her strength is ");
  549.         printnum (strength[i]);
  550.         writechar ('\n');
  551.     }
  552.     }
  553. }
  554.  
  555. take (person,thing)
  556. short person,thing;
  557. {
  558.     move (charpos[person],-person,thing);
  559.     if (person && charpos[person]==charpos[0])
  560.     {
  561.     perdesc (person,0);
  562.     print (" takes the");
  563.     print (obj_desc[thing]);
  564.     print (".\n");
  565.     }
  566. }
  567.  
  568. walk (person,d)
  569. short person,d;
  570. {
  571.     err=FALSE;
  572.     if (d==0)
  573.     d=-(MAXX+1);
  574.     if (d==1)
  575.     d=MAXX+1;
  576.     if (d==2)
  577.     d=1;
  578.     if (d==3)
  579.     d=-1;
  580.     if (legal (charpos[person]+d)==FALSE)
  581.     err=TRUE;
  582.         else
  583.         {
  584.             charpos[person]+=d;
  585.             if (person && charpos[person]==charpos[0])
  586.             {
  587.                 perdesc (person,1);
  588.                 print (" arrives.\n");
  589.             }
  590.         }
  591. }
  592.  
  593. otget (person)  /* Make character grab everything possible */
  594. short person;    /* Purpose of order here is to make character take most */
  595. {        /* powerful weapons first. */
  596.     taken=TRUE;
  597.     if (numweap (charpos[person],4)) take (person,4); else
  598.     if (numweap (charpos[person],2)) take (person,2); else
  599.     if (numweap (charpos[person],1)) take (person,1); else
  600.     if (numweap (charpos[person],3)) take (person,3); else
  601.     if (numweap (charpos[person],6)) take (person,6); else
  602.     if (numweap (charpos[person],5)) take (person,5); else
  603.     if (numcoin (charpos[person])) take (person,8); else
  604.     taken=FALSE;
  605. }
  606.  
  607. main ()
  608. {
  609.     struct dos_time_t T;
  610.     dos_gettime (&T);
  611.     srand (((T.minute/12)*6000) + T.second*100 + T.hsecond);
  612.     verbose=TRUE;
  613. AGAIN:
  614.     dead=FALSE;
  615.     print ("Welcome to Labyrinth by Russell Wallace.\n");
  616.     print ("Do you want instructions? (Y/N) : ");
  617.     if (yesno ())
  618.     {
  619.      print ("Labyrinth was originally written in Pascal on a PDP 11-73 \
  620. minicomputer, converted to C and ported to the Amiga, and then in this version \
  621. ported to MS-DOS.\n\
  622. Labyrinth is a role-playing game in which \
  623. you wander around a series of underground caves fighting the \
  624. computer-controlled characters and amassing treasure. The ultimate \
  625. object of the game is to kill all the other characters having \
  626. collected as many as possible of the 300 or so coins lying around \
  627. the caves. The other characters will be doing the same thing, and \
  628. will usually attack anyone they see including you. If attacked, \
  629. use your most effective weapon (your fist if nothing else is \
  630. available). Blows will reduce your strength; if this falls to zero \
  631. you die. As time passes it will gradually build up again but can \
  632. never exceed your power. Everyone starts with a power of 300 and \
  633. if you kill somebody, a quarter of their power is added to yours, \
  634. and you can pick up anything they might have been carrying. When \
  635. everyone else is dead your money will be added to your score which \
  636. will be carried over to the next game.\n\
  637. Labyrinth is a work of fiction and no similarity to any real \
  638. places or events is intended or implied, however most of the \
  639. computer-controlled characters are named after people from my \
  640. class in St. Andrews College in order to make the game more \
  641. interesting.\n\
  642. The following commands are available:\n\
  643. TAKE object            - pick up something\n\
  644. DROP object            - put down something\n\
  645. HIT person WITH object - commit an act of violence\n\
  646. INVENTORY              - list your possessions etc.\n\
  647. VERBOSE                - describe surrounding locations\n\
  648. BRIEF                  - only describe current location\n\
  649. NORTH,SOUTH,EAST,WEST  - move around\n\
  650. QUIT                   - terminate game\n\
  651. LOCAL                  - narrate events only where you are\n\
  652. GLOBAL                 - narrate combat elsewhere in brackets\n\
  653. REDESCRIBE               current location\n\
  654. All commands can be abbreviated to the first letter, and the word \
  655. WITH can be omitted entirely. Refer to people by first names only. \
  656. Object names can also be abbreviated to one or two letters.\n\n\
  657. Press any key to start ");
  658.     if (waitinput ()==-1000)
  659.     {
  660.         exit (0);
  661.     }
  662.     }
  663.      writechar ('\n');
  664.     do
  665. {    /* This loop will execute as long as game not over */
  666.     for (i=0;i<=NUMCHAR;i++)
  667.     {
  668.     charpos[i]=rnd (NUMLOC-1)+1;
  669.     if (legal (charpos[i])==FALSE)
  670.         charpos[i]++;
  671.     power[i]=strength[i]=300;
  672.     }
  673.     for (i=1;i<=NUMTYPE-2;i++)
  674.     for (j=1;j<=NUMWEAP;j++)
  675.         weapos[i][j]=rnd (NUMLOC)+1;
  676.     for (i=1;i<=NUMCOIN;i++)
  677.     coinpos[i]=rnd (NUMLOC)+1;
  678.     see=TRUE;    /* Describe location game starts in */
  679.     do
  680. {    /* This loop will execute until game over or won */
  681.     if (see)
  682.     {
  683.     print ("You are in");
  684.     look (charpos[0]);
  685.     population (charpos[0]);
  686.     if (numpos (charpos[0]))
  687.     {
  688.         print ("You can also see:\n");
  689.         locdesc (charpos[0]);
  690.     }
  691.     if (verbose)
  692.     {
  693.         print ("To the north you can see");
  694.         look (charpos[0]-(MAXX+1));
  695.         print ("To the south you can see");
  696.         look (charpos[0]+MAXX+1);
  697.         print ("To the east you can see");
  698.         look (charpos[0]+1);
  699.         print ("To the west you can see");
  700.         look (charpos[0]-1);
  701.     }
  702.     see=FALSE;
  703.     }
  704.     print ("What now? :");
  705.     command=getstring ();
  706.     for (i=0;i<INLEN;i++)
  707.     command[i]=tolower (command[i]);
  708.     index=0;
  709.     if (command[0]=='l')
  710.     global=FALSE;
  711.     if (command[0]=='g')
  712.     global=TRUE;
  713.     if (command[0]=='b')
  714.     verbose=FALSE;
  715.     if (command[0]=='v')
  716.     verbose=TRUE;
  717.     if (command[0]=='i')
  718.     {
  719.     if (numpos (0)==0)
  720.         print ("You are emptyhanded.\n");
  721.         else
  722.         {
  723.             print ("You are carrying:\n");
  724.             locdesc (0);
  725.         }
  726.     print ("Your strength is ");
  727.     printnum (strength[0]);
  728.     print ("\nYour power is ");
  729.     printnum (power[0]);
  730.     print ("\nYour score is ");
  731.     printnum (score+numcoin (0));
  732.     writechar ('\n');
  733.     }
  734.     if (command[0]=='q')
  735.     {
  736.     print ("OK, so long.\n");
  737.     dead=TRUE;
  738.     goto FINISH;
  739.     }
  740.     if (command[0]=='t')
  741.     {
  742.     thing=getname (command);
  743.     if (thing==7)
  744.         print ("It seems to be attached to your arm.\n");
  745.         else
  746.             if (thing)
  747.             {
  748.             take (0,thing);
  749.             if (err)
  750.                 print ("I see none here.\n");
  751.                 else
  752.                     print ("Taken.\n");
  753.             }
  754.     }
  755.     if (command[0]=='d')
  756.     {
  757.     thing=getname (command);
  758.     if (thing==7)
  759.         print ("Amputation is very unpleasant.\n");
  760.         else
  761.             if (thing)
  762.             {
  763.             drop (0,thing);
  764.             if (err)
  765.                 print ("You have none to drop.\n");
  766.                 else
  767.                     print ("Dropped.\n");
  768.             }
  769.     }
  770.     if (command[0]=='r')
  771.     see=TRUE;
  772.     if (command[0]=='n')
  773.     walk (0,0);
  774.     if (command[0]=='s')
  775.     walk (0,1);
  776.     if (command[0]=='e')
  777.     walk (0,2);
  778.     if (command[0]=='w')
  779.     walk (0,3);
  780.     if (command[0]=='n' || command[0]=='s' || command[0]=='e' || command[0]=='w')
  781.     if (err)
  782.         print ("You bang your face off the wall as you attempt this.\n");
  783.         else
  784.             see=TRUE;
  785.     if (command[0]=='h')
  786.     {
  787.     getword (command);
  788.     tarnum=0;
  789.     for (i=1;i<=NUMCHAR;i++)
  790.         if (strcmp (inword,pername[i])==0 && charpos[i]==charpos[0])
  791.         tarnum=i;
  792.     if (tarnum==0)
  793.         print ("There is nobody here by that name.\n");
  794.         else
  795.         {
  796.             weapon=getname (command);
  797.             if (weapon)
  798.             if (numweap (0,weapon)==0)
  799.                 print ("You have none to use.\n");
  800.                 else
  801.                     attack (0,tarnum,weapon);
  802.         }
  803.     }
  804.     for (i=1;i<=NUMCHAR;i++)    /* Now handle computer characters */
  805.     {
  806.     otget (i);      /* Grab everything in sight */
  807.     if (taken==0) { /* If nothing to take, then fight */
  808.     fought=FALSE;
  809.     j=-1;
  810.     do
  811.     {   /* look for someone to fight */
  812.         j++;
  813.         if (charpos[i]==charpos[j] && i!=j && charpos[i]!=NOWHERE)
  814.         {
  815.         fought=TRUE;    /* found someone, now choose weapon */
  816.         atstre=22;
  817.         atweap=7;    /* default weapon is fist */
  818.         for (z=1;z<=NUMTYPE-2;z++)
  819.         {
  820.             if (hitval[z]>atstre && numweap (-i,z))
  821.             {
  822.             atweap=z;
  823.             atstre=hitval[z];
  824.             }
  825.         }
  826.         }
  827.     }
  828.     while (fought==0 && j<NUMCHAR);
  829.     if (fought)
  830.         attack (i,j,atweap); }
  831.     if (taken==0 && fought==0)
  832.         walk (i,rnd (4));   /* if nothing else to do, wander around */
  833.     }
  834.     alldead=TRUE;
  835.     for (i=0;i<=NUMCHAR;i++)
  836.     {
  837.     if (i && charpos[i]>NOWHERE)
  838.         alldead=FALSE;
  839.     strength[i]+=6;     /* gradual recovery */
  840.     if (strength[i]>power[i])
  841.         strength[i]=power[i];
  842.     }
  843. }
  844.     while (dead==FALSE && alldead==FALSE);
  845.     score+=numcoin (0);
  846.     if (alldead)
  847.     print ("Congratulations ... you've killed everyone else in the game! A new game is now starting, with your money from the old added to your score.\n");
  848. }
  849.     while (dead==FALSE);
  850. FINISH:
  851.     score=0;
  852.     print ("Game over. Would you like to play again? (Y/N) : ");
  853.     if (yesno ())
  854.     goto AGAIN;
  855. }
  856.  
  857. char *getstring ()
  858. {
  859.     if (input (inputbuffer,MAXBUF)==-1000)
  860.     {
  861.     exit (0);
  862.     }
  863.     return (inputbuffer);
  864. }
  865.  
  866. int yesno ()
  867. {
  868.     char c;
  869.     do
  870.     c=waitinput ();
  871.     while (c!='y' && c!='Y' && c!='n' && c!='N');
  872.     writechar (c);
  873.     writechar ('\n');
  874.     return (c=='y' || c=='Y');
  875. }
  876.  
  877.